<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>确认信息</title>
    <link href="https://unpkg.com/layui@2.7.6/dist/css/layui.css" rel="stylesheet">
    <script src="https://unpkg.com/layui@2.7.6/dist/layui.js"></script>
    <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
</head>

<body>
    <div class="content">
        <form class="layui-form layui-form-pane" action="">
            <div class="layui-form-item" pane="">
                <label class="layui-form-label">区域名称</label>
                <div class="layui-input-block">
                    <input type="text" name="name"  lay-verify="required" placeholder="输入名称" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">距离提醒：</label>
                <div class="layui-input-block">
                    <select name="interest" lay-filter="aihao">
                        <option value="0">5米</option>
                        <option value="1">10米</option>
                        <option value="2">15米</option>
                        <option value="3">30米</option>
                        <option value="4">50米</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">备注：</label>
                <div class="layui-input-block">
                    <textarea placeholder="请输入内容" class="layui-textarea" name="desc"></textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <button class="layui-btn layui-bg-blue" type="submit" lay-submit="" lay-filter="submit_info">确认创建</button>
                <button type="button" class="layui-btn layui-bg-red">返回修改</button>
            </div>
        </form>
    </div>
</body>
<script type="text/javascript">
    let par_data = [];
    var edit = function(table_id, Longitude_latiude) {
        par_data.push(table_id);
        par_data.push(Longitude_latiude);
    }

    var form = layui.form;
    //提交
    form.on('submit(submit_info)', function(data) {
        data.field["timestamp"] = <?php echo time(); ?>;
        data.field["table_id"] = par_data[0];
        data.field["Longitude_latiude"] = par_data[1];
        data.field["add"] = 'add';
        console.log(data.field);
        $.ajax({
            url: './sql_up.php',
            method: 'post',
            data: data.field,
            dataType: 'JSON',
            success: function(res) {
                if (res.code == '0') {
                    console.log(res.msg);
                    layer.msg(res.msg, {
                        icon: 1,
                        time: 3000
                    }, function() {
                        location.reload();
                    });
                } else
                    layer.msg(res.msg, {
                        icon: 0,
                        time: 3000
                    });
            },
        });
        return false;
    });
</script>

</html>